package com.xuhuan.admin.vo.sysmenu;

import cn.hutool.core.lang.UUID;
import java.util.List;
import lombok.Data;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;

/**
 * @author: huan.xu
 * @create: 2024/7/9 17:21
 * @description: 菜单信息
 **/
@Data
public class SysMenuInfoVO {

  public SysMenuInfoVO() {
  }

  public SysMenuInfoVO(Long id, String name, String icon, Integer order, String url,
      List<SysMenuInfoVO> childList) {
    this.id = id;
    this.name = name;
    this.icon = icon;
    this.order = order;
    this.url = url;
    String code = "code"+UUID.fastUUID().toString(true).substring(0,4)+"-nav";
    this.code= code;
    if(CollectionUtils.isNotEmpty(childList)){
      this.targetAttr = "#" + code;
    }
    if (StringUtils.isNotBlank(targetAttr)) {
      this.targetId = targetAttr.substring(1, targetAttr.length());
    }
    this.childList = childList;
  }

  /**
   * 菜单ID
   */
  private Long id;
  /**
   * 菜单名称
   */
  private String name;
  /**
   * 菜单图标
   */
  private String icon;
  /**
   * 菜单序号
   */
  private Integer order;
  /**
   * url
   */
  private String url;
  /**
   * html需要的标记
   */
  private String targetAttr;
  /**
   * 标记ID，就是去掉targetAttr前面的#
   */
  private String targetId;
  /**
   * 唯一标识
   */
  private String code;
  /**
   * 子菜单
   */
  private List<SysMenuInfoVO> childList;

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getIcon() {
    return icon;
  }

  public void setIcon(String icon) {
    this.icon = icon;
  }

  public Integer getOrder() {
    return order;
  }

  public void setOrder(Integer order) {
    this.order = order;
  }

  public String getUrl() {
    return url;
  }

  public void setUrl(String url) {
    this.url = url;
  }

  public String getTargetAttr() {
    return targetAttr;
  }

  public void setTargetAttr(String targetAttr) {
    this.targetAttr = targetAttr;
  }

  public String getTargetId() {
    return targetId;
  }

  public void setTargetId(String targetId) {
    this.targetId = targetId;
  }

  public List<SysMenuInfoVO> getChildList() {
    return childList;
  }

  public void setChildList(List<SysMenuInfoVO> childList) {
    this.childList = childList;
  }

  public static void main(String[] args) {
    System.out.println(UUID.fastUUID().toString(true));
  }
}
